﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Devonline.Core;
using Mapster;

namespace Devonline.Entity
{
    /// <summary>
    /// 基础数据, 字符串类型的默认实现
    /// </summary>
    [Table("parameter"), DisplayName("基础数据")]
    public class Parameter : Parameter<string>
    {
        /// <summary>
        /// 父项基础数据
        /// </summary>
        [AdaptIgnore]
        public virtual Parameter Parent { get; set; }
        /// <summary>
        /// 子项基础数据
        /// </summary>
        [AdaptIgnore]
        public virtual ICollection<Parameter> Children { get; set; }
    }

    /// <summary>
    /// 基础数据
    /// </summary>
    [Table("parameter"), DisplayName("基础数据")]
    public abstract class Parameter<TKey> : EntitySetWithKeyValuePair<TKey>, IEntitySetWithKeyValuePair<TKey> where TKey : IConvertible
    {
        /// <summary>
        /// 基础数据项显示的文本
        /// </summary>
        [Column("text"), DisplayName("文本"), Required, MaxLength(128), Excel]
        public virtual string Text { get; set; }
        /// <summary>
        /// 父项编号
        /// </summary>
        [Column("parent_id"), DisplayName("父级编号"), MaxLength(36), Excel]
        public virtual TKey ParentId { get; set; }
    }
}
